/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wli.java.db;

import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author liw
 */
public class TargetHelper {

    private List<TargetId> idList;
    Session session = null;

    public TargetHelper() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }

    public List getTargetList() {
        System.out.println(">>>>>>>AAAAAAAAAAAAAAAAAAAA>>>>>>>>>>>>>>>>");
        List<Target> list = null;

        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Criteria crit = session.createCriteria(Target.class);
            list = crit.list();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }

    public List getTargetList(String asset_id) {
        List<Target> list = null;
        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Target as targ where targ.asset_id='" + asset_id + "'");
            list = (List<Target>) q.list();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
